package data

import (
	"fcs-api/src/app/model"
	"log"
)

var ResourceMap map[string]*model.FuncInfo
var CreateIdForNameMap map[string]string
var DataStoreErr bool = false

func GetResourceIdList() ([]string, []string) {
	/*
		@return  resourceIdList []string
		TODO
	*/
	//resourceIdList := xxxx.GetResourceIdList()
	var resourceIds []string
	users := []string{}
	ResourceMap = map[string]*model.FuncInfo{}
	CreateIdForNameMap = map[string]string{}
	funcList, err := model.GetAllFuncInfoList()
	if err != nil {
		log.Println("get func list err ", err)
		DataStoreErr = true
	} else {
		DataStoreErr = false
	}
	for _, funcInfo := range funcList {
		ResourceMap[funcInfo.Id] = funcInfo
		CreateIdForNameMap[funcInfo.Creator] = funcInfo.CreatorName
		resourceIds = append(resourceIds, funcInfo.Id)
		repeat := false
		for _, user := range users {
			if user == funcInfo.CreatorName {
				repeat = true
				break
			}
		}
		if !repeat {
			users = append(users, funcInfo.CreatorName)
		}
	}
	return resourceIds, users
}
